import dayjs from 'dayjs'
import logo from '@image/logo.png'
import logo2 from '@image/logo2.png'

let CONFIG = import.meta.env

export const KEY = 'TXZ'

export const SHORT_NAME = '万路优品'

export const NAME = '万路优品'

export const global = {
    logoUrl: [logo, logo2], //logo ,第一个是小logo,第二个是大logo
    appId: '2021003133625134' //小程序id-商品管理二维码使用
}

export const SERVE_URL = CONFIG.VITE_SERVER_URL
export const imgSERVEURL = CONFIG.VITE_OSS_URL;

export const ADMIN_LINK = CONFIG.VITE_ADMIN

export const regionDateShortcuts = [
    {
        text: '最近3天',
        value: (() => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 2)
            end.setTime(end.getTime())
            return [start, end]
        })()
    },
    {
        text: '最近7天',
        value: (() => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 6)
            end.setTime(end.getTime())
            return [start, end]
        })()
    },
    {
        text: '最近15天',
        value: (() => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 14)
            end.setTime(end.getTime())
            return [start, end]
        })()
    }
]

export const regionDateShortcuts2 = [
    {
        text: '当天',
        value: (() => {
            const end = new Date()
            const start = new Date()
            return [start, end]
        })()
    },
    {
        text: '最近3天',
        value: (() => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 2)
            end.setTime(end.getTime())
            return [start, end]
        })()
    },
    {
        text: '最近一周',
        value: (() => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 6)
            end.setTime(end.getTime())
            return [start, end]
        })()
    },
    {
        text: '最近两周',
        value: (() => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 13)
            end.setTime(end.getTime())
            return [start, end]
        })()
    },
    {
        text: '最近一个月',
        value: (() => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
            end.setTime(end.getTime())
            return [start, end]
        })()
    }
]
export const regionDateShortcuts3 = [
    {
        text: '本周',
        value: (() => {
            // const end = new Date()
            // const start = new Date()
            // start.setTime(start.getTime() - 3600 * 1000 * 24 * 6)
            // end.setTime(end.getTime())

            const date = new Date()
            const weekday = date.getDay() || 7
            let end = date.getTime()
            end = dayjs(end).format('YYYY-MM-DD 23:59:59')
            date.setDate(date.getDate() - weekday + 1)
            let start = date.getTime()
            start = dayjs(start).format('YYYY-MM-DD 00:00:00')
            return [start, end]
        })()
    },
    {
        text: '上周',
        value: (() => {
            // const end = new Date()
            // const start = new Date()
            // start.setTime(start.getTime() - 3600 * 1000 * 24 * 13)
            // end.setTime(end.getTime() - 3600 * 1000 * 24 * 6)

            const date = new Date()
            const weekday = date.getDay() || 7
            date.setDate(date.getDate() - weekday + 1)
            let end = date.getTime()
            end = dayjs(end).format('YYYY-MM-DD 23:59:59')
            date.setDate(date.getDate() - 7)
            let start = date.getTime()
            start = dayjs(start).format('YYYY-MM-DD 00:00:00')
            return [start, end]
        })()
    },
    {
        text: '本月',
        value: (() => {
            // const end = new Date()
            // const start = new Date()
            // start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
            // end.setTime(end.getTime())

            const date = new Date()
            let end = date.getTime()
            end = dayjs(end).format('YYYY-MM-DD 23:59:59')
            date.setDate(1)
            let start = date.getTime()
            start = dayjs(start).format('YYYY-MM-DD 00:00:00')
            return [start, end]
        })()
    },
    {
        text: '上月',
        value: (() => {
            // const end = new Date()
            // const start = new Date()
            // start.setTime(start.getTime() - 3600 * 1000 * 24 * 60)
            // end.setTime(end.getTime() - 3600 * 1000 * 24 * 30)

            const date = new Date()
            date.setDate(1)
            let end = date.getTime() - (3600 * 1000 * 24)
            let start = end - (3600 * 1000 * 24) * 30
            end = dayjs(end).format('YYYY-MM-DD 23:59:59')
            start = dayjs(start).format('YYYY-MM-DD 00:00:00')
            return [start, end]
        })()
    },
    {
        text: '本季度',
        value: (() => {
            // const end = new Date()
            // const start = new Date()
            // start.setTime(start.getTime() - 3600 * 1000 * 24 * 30 * 3)
            // end.setTime(end.getTime())

            const y = new Date().getFullYear();  //当前年份  
            const m = new Date().getMonth();  //当前月份
            const q = parseInt(m / 3);  //当前季度
            let start = new Date(y, (q - 0) * 3, 1);  //上一季度的开始日期
            let end = new Date();  //动态
            end = dayjs(end).format('YYYY-MM-DD 23:59:59')
            start = dayjs(start).format('YYYY-MM-DD 00:00:00')
            return [start, end]
        })()
    },
    {
        text: '上季度',
        value: (() => {
            // const end = new Date()
            // const start = new Date()
            // start.setTime(start.getTime() - 3600 * 1000 * 24 * 30 * 6)
            // end.setTime(end.getTime() - 3600 * 1000 * 24 * 30 * 3)

            const y = new Date().getFullYear();  //当前年份  
            const m = new Date().getMonth();  //当前月份
            const q = parseInt(m / 3);  //当前季度
            let start = new Date(y, (q - 1) * 3, 1);  //上一季度的开始日期
            let end = new Date(y, q * 3, 0);  //上一季度的结束日期
            end = dayjs(end).format('YYYY-MM-DD 23:59:59')
            start = dayjs(start).format('YYYY-MM-DD 00:00:00')
            return [start, end]
        })()
    }
]